#pragma once
#include <memory>
#include "data.h"
#include "Singleton.h"
#include <mutex>
#include <unordered_map>

class CSession;
// 用户管理器
class UserMgr:public Singleton<UserMgr>
{
    friend class Singleton<UserMgr>;
public:
    ~UserMgr();
    void RemoveUserSession(int uid);
    std::shared_ptr<CSession> GetSession(int uid);
    void SetUserSession(int uid,std::shared_ptr<CSession>);
    
private:
    UserMgr();

private:
    std::unordered_map<int,std::shared_ptr<CSession>> uid_to_session_;
    std::mutex session_mtx_;

};
